package udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/17 18:01
 * @description UDP服务端
 */
public class UdpServer {
    public static void main(String[] args) throws Exception {
        DatagramSocket datagramSocket = new DatagramSocket(9090);
        byte[] bytes = new byte[1024];
        DatagramPacket packet = new DatagramPacket(bytes, 0, bytes.length);
        datagramSocket.receive(packet);
        System.out.println(packet.getAddress().getHostAddress());
        datagramSocket.close();
    }
}
